<createExampleNode.controlFlowDataStructure>

Continuing from createExampleNode.13.xml

<summaryOfProblems>
	I am finding it hard to merge trees of Func that represent sizes with trees of Func that control current index in iteration, and by getting arrays from child nodes from a small constant depth, I lose the ability to calculate the iteration size before the iteration starts.

	All descendant Funcs of the one you call must do their whole iteration, or the other option is to tell it to run the next iteration part without knowing how many more there are.

	Even if we could know the iteration size before iterating, the Funcs that are used the most will be optimized as Java classes and lose that ability, or partially optimized and keep some of that ability.
</summaryOfProblems>

<goal>
	Need to stop thinking about data structures for now and define the behavior I want, then define the data structures.
</goal>

aray = a real aray in memory.
	Examples: int[], Object[], double[], Func[].
	Contains the same type of things. Specific indexs can not be defined to contain different types of things.
	Maybe: aray extends indirectAray, and indirectAray extends virtualList.

indirectAray = a real aray or an aray found recursively through child nodes.
	Maybe: aray extends indirectAray, and indirectAray extends virtualList.
	Example: virtualFloListAtIndex19 could be defined as the floListAtIndex10 aray of the current child in childListAtIndex5,
	and when iterating over childListAtIndex5, virtualFloListAtIndex19 becomes the floListAtIndex10 of a different child node each time.
	All arays can be defined as virtualAray if the root node is defined as a child of the funcState,
	and that would be faster for some calculations because arays that are not used would not have to be put in the funcState.

virtualList = like an aray but having no data lets it be much bigger. Its used for iterating over combinations of arrays and doing trees of calculations and reads/writes.
	Maybe: aray extends indirectAray, and indirectAray extends virtualList.
	(Maybe this should be combined with Func. Maybe virtualAray should be combined with aray. Many combinations are possible to be good design.)

node = constant-size obAray containing different types of arays whose sizes depend on eachother and are defined using 1 of these Func per aray:
	range(between 2 int constants)
	size*(x y)
	size^(x y)
	Node does not extend aray because aray "Contains the same type of things. Specific indexs can not be defined to contain different types of things."

virtualNode = A virtual interpretation of a + function, and real aray are only created in funcState, and funcState may contain other funcState. funcState are defined as virtual so all data in the whole software would be virtual until its copied to a file. Its similar to size* and size^ because it combines 2 things which can be different types, but is different because only 1 of those 2 things is used at a time, which would make iterating hard to define. It would allow optimizations like combining 4 size-1 floArays into 1 size-4 floAray.

funcState = All information and/or data structures and/or Funcs that a Func uses to store things in while it reads/writes things in a node. A funcState is created already containing some of these things in the node, then is the parameter of a Func call which does something to that node and/or its descendants. FuncStates may be recursive. Each funcState represents at most a small constant quantity of specific recursions. An example of constant depth specific recursion is add child of child of child's seventh flo to child of childs third flo.
	There can be many polyIndex in a funcState.

func = an object with a function that takes 1 funcState parameter (or the parts of a funcState each as a different parameter) and returns in a predictable maximum time. There may be multiple standard ways to call every Func, including:
	* Do the smallest amount of things possible.
	* Do constant-depth-recursion in 1 funcState and return any funcStates that need to be called, and allow continuing execution after you execute those funcStates separately.
	* Do the whole unpredictable-max-time variable-depth-recursion.
	Each Func has 0 or more child Funcs and that never changes.
	OPTIMIZABLE: Some trees of Func can be ***optimized as a Java class*** that does the same thing as the tree but is 1 Func that has as many parameters as the inputof the root plus the outputs of the leafs in the tree had. An optimized version of a Func can use the same types of funcState but could also create a different optimized version that uses a smaller funcState that excludes the indexs used for the middle of the calculation (Its best to remove those because they are ignored and other code may, but shouldnt, expect them to be used).
	Each func modifies the int indexs and/or aray in a polyIndex, and/or modifies the data in arays in a node.
	Example func: flo+=flo(floArayA floArayB)
	Example func: factor^(bPowerCThenMultC bPowerC c setIndexOfBHere) or maybe it should be remove^(bPowerC c setIndexOfBHere) or remove^*(bPowerCThenMultC setIndexOfBHere)

How to define constraints on the content of some arrays?
	Example: the 2 intAray in a heapQueue must always point at eachother symmetricly.
	Example: the floAray in a heapQueue must run a heapQueueFunc on floAray and 2 intArays in the heapQueue, to reorder the flo in the 2 intAray if the flo changed enough. After that func is done, the root index (is it 0 or 1?) of the first intAray must contain the int index of the max flo in floAray.

========================================

<thisIsTooMuchAboutOpimizationAndNotEnoughAboutDefiningBehavior>
	polyIndex = Data is: 1 or more int indexs in the same aray, and the aray. This avoids most of the need to have multiple variables pointing at the same aray.
		Maybe: polyIndex extends virtualList of int.
		PolyIndex may complicate the design too much and be replaced by 1 int index per 1 pointer to aray, and allow duplicate pointers to the same aray while having different or equal int indexs for it.
</thisIsTooMuchAboutOpimizationAndNotEnoughAboutDefiningBehavior>

polyIndex includes multiple int index and 1 aray. Should it also have multiple aray from the same node that are equal size?
Or should there be 2 different types of things: monoArayPolyIndex and polyArayMonoIndex?

For now, ignore efficiency and how to implement this and exactly define the behavior we want.

simpleArayGroup = the information in, but not the data structure of, these 3 arays:
	* int curIndex[any size], contains independent ints between 0 and arayAray[0].length-1.
	* int whichAray[curIndex.length], contains independent ints between 0 and arayAray.length-1.
	* Object arayAray[any size], contains any arays that are always the same size and can be different types.
This may be useful for optimizing nodes where some arays must be the same size always, but the behavior should be defined before starting on optimizations like these.

virtualNode (abbrev: vn) = The information but not data structures of...
	* a view of a single variable-size aray, and a current int index, or
	* virtualNodeA + virtualNodeB (should it allow any constant quantity of virtualNodes instead of just 2?), and a current int index from 0 to sum of their sizes - 1.
VirtualNode can give many subVirtualNodes as efficiently as String can give many substrings.

A bayesian algorithm would use:
bayesNode = vnFalseTrue + vnChilds + vnWeights + vnWeightSums
vnFalseTrue = between 2 and 2
vnChilds = between 1 and 7
vnWeights = vnFalseTrue ^ vnChilds
vnWeightSums = vnFalseTrue * vnChilds

bayesNode = vnFalseTrue + vnChilds + (vnFalseTrue^vnChilds) + (vnFalseTrue*vnChilds)

Should aray of x size y be defined as x^y?
Example: int = bit^32
Example: int[3] = (bit^32)^3
Example: Object[]{ int[3], flo[4] } = (bit^32)^3 + (definition of flo)^4

Maybe there should be no flo, and use arays of bits (often optimized as java ints) instead, converting them to flo only in the middle of calculations that need flos like java.lang.Math.sin(flo).

Define iterating over all possible int values as bit^32.
Define each specific int value as bit*32.
Define int[3] as (bit*32)^3. This definition is vague. What size loop? How many data (1 or 3) in each iteration?

Define ^ as loop.
Define * as specific value.
What should bit be defined as? Should bit be one of 0 or 1? Should bit be one of * or ^?
Should [+, *, ^] be viewed as [-1, 0, 1]?
Should [+, *, ^] be viewed as [0, 1, []]?
Or, similar to a base-negativetwo or base-negativethree or base-sqareRootOfNegativeFour positional number system,
should one of Audivolv's main data types be number whose base is defined as some combination of * and ^?
Maybe call it a base-specificValueXorLoop positional number system. I'm not sure about the Xor, but "specificValue" and "Loop" must have some logic word between them.

Simplify. Ignoring efficiency and data structures, list the main ideas here:
* literal(x) //1 time, not a loop. observe a qubit or combination of them, or observe the fact that they are qubits in some combination without observing their values.
* 0
* 1
* qubit //May be 0 or 1, until observed by a loop(x). http://en.wikipedia.org/wiki/Qubit
* loop(x) //observe all possible combinations of x, viewing each as literal
* cat(x y)

Examples:
cat(cat(1 0) 1) is 5
cat(cat(1 qubit) 1) is 2 possible things: 101 and 111.
loop(cat(cat(1 qubit) 1)) is both in sequence: 101 then 111.
literal(loop(cat(cat(1 qubit) 1))) is the literal description of "both in sequence: 101 then 111".

cnum(x y) = a complex number of this form: x + sqrt(-1)*y.
cnum(x y)^2 = (x + sqrt(-1)*y)*(x + sqrt(-1)*y) = x^2 - y^2 + sqrt(-1)*2*x*y

If cnum(b c)^2 + cnum(d e)^2 == 1, then:
b^2 - c^2 + sqrt(-1)*2*b*c + d^2 - e^2 + sqrt(-1)*2*d*e == 1
and simplified:
b^2 - c^2 + d^2 - e^2 == 1
and
b*c + d*e == 0

Are complex numbers and quantum equations useful in any way for defining loops, variables, and control-flow in Audivolv?

A normal bayesian-node with 5 child nodes (including itself) has 32 chances that sum to 1. Should each chance be a complex number? Should each chance be a recursively complex number defined as some tree of child bayesian-nodes (avoiding exponential cost by running each node only once)?

Every normal bayesian network is a quantum bayesian network where all complex numbers have 0 imaginary (sqrt(-1)) part.

An internet search for "quantum bayesian" finds lots of pages. Some are from the 1990s and claim that quantum bayesian networks would fun faster on a quantum computer than a normal computer.

Again...
list the main ideas here:
* literal(x) //1 time, not a loop. observe a qubit or combination of them, or observe the fact that they are qubits in some combination without observing their values.
* 0
* 1
* varBit //May be 0 or 1, until used by loop(x)
* loop(x) //observe all possible combinations of x, viewing each as literal
* cat(x y)

Examples:
cat(cat(1 0) 1) is 5
cat(cat(1 varBit) 1) is 2 possible things: 101 and 111.
loop(cat(cat(1 varBit) 1)) is both in sequence: 101 then 111.
literal(loop(cat(cat(1 varBit) 1))) is the literal description of "both in sequence: 101 then 111". This is confusing.

These things can not simply represent integers that are not powers of 2.
Instead, define these higher level main ideas:
* int = a specific nonnegative integer
* cat(x y z...) = aray containing x, y, z...
* *(x y) = multiply operator. Resulting size: x multiply y. For each thing in the resulting size: 1 variation of x and 1 variation of y.
* ^(x y) = power operator. Resulting size: x power y. For each thing in the resulting size: y quantity of variations of x.
Maybe cat should be renamed to +.
* +(x y) = concatenate operator. Resulting size: x plus y. For each thing in the resulting size: 1 variation of x or 1 variation of y, and maybe: 1 int index in the aray that contains x and y.
Example: b is size 5. c is size 10. d is size 12. e is size 3. +(b c d e) is size 30, and for each of those 30 things, there are 2 ints.
Those 30 things range 0 to 29.
Thing number 4 gives [0,4].
Thing number 5 gives [1,0].
Thing number 8 gives [1,3].
Thing number 29 gives [3,2] because e is array number 3 and b+c+d+2 is 29.
This is a good way to abstractly define concat.

Should ^(x y) be defined as giving an array size y for each of x^y quantity of things? Aray is +. If y is 5, then it gives 32 arrays like this: +(x x x x x) with 5 specific values of x. Maybe *(x y) is better because "each thing in the resulting size" is size 2 instead of size 5. +(x x x x x) is more correct if it is not iterated over. Just use the 5 specific values of x.

//b is 2. c is 3. d is 4. e is 5. f is 6.

int
+(b c) - Iteration size can not be simplified. Data size is +(x y) where x is size 2 and size of y depends on value of x. size of y is size of b or size of c.
//Approximations: iteration size eval(+(b c)) - data size is not cartesian. +(+(2 b) +(2 c)), +(2 or(b c)), +(+(1 b) +(1 c)), +(b c)
*(b c) - iteration size +(b b b)     - data size +(b c).
^(b c) - iteration size *(b b b)     - data size +(b b b).

//Theoretically, if this pattern continues, what is the next operator?
?(b c)  - iteration size ^(b b b)? - data size *(b b b)

^(^(b b) b) <= ^(b ^(b b))
Example: 5^5 = 3125
^(^(5 5) 5) = 298023223876953125
^(b ^(b b)) = 1.911012597945477520356404559704e+2184

^(^(2 2) 2) = 16
^(^(3 3) 3) = 19683
^(^(4 4) 4) = 4294967296

This theoretical operator creates numbers that are too big to be practical in AI algorithms.
The only operators needed for aray size and iterating are:
+ plus/concat
* multiply
^ power

Iteration size of x is always 1 integer, the same as eval(x).
Data of x is different in each eval(x) quantity of iterations and is always an aray.

b is 2. c is 3.

+(b c) - Data is +(2 b) or +(2 c), depending on the value of the thing that is size 2.
*(b c) - Data is +(b c).
^(b c) - Data is +(b b b). //Data of +(b b b) is +(b c) because c is 3.

^(c b) - Data is +(c c). //Data of +(c c) is +(c b) because b is 2.



Is +(b b b) an operator? It is the + of variations of the same type of thing.

+(b c)                                         --> +(2 b) or +(2 c)
*(b c)                              --> +(b c) --> +(2 b) or +(2 c)
varSize+(b b b)                     --> +(b c) --> +(2 b) or +(2 c)
^(b c)          --> varSize+(b b b) --> +(b c) --> +(2 b) or +(2 c)

Some of those transformations lose information and some dont.

Example: Given current values of b and c, and constant sizes of b and c,
[+(b c) --> +(2 b) or +(2 c)] loses 1 of the current values.
[+(b c) --> +(2 b) and +(2 c)] loses nothing, and the values of each 2 are redundant.

Example: Given current values of each b, and constant size of b and size of the varSize+ is the size of c,
[varSize+(b b b) --> +(b c)] keeps only the current value of 1 b, and the value of c which tells which b.

Need to specify more detail about size, current index, and array vs iterating over that array, and recursion.

Should varSize*(b b b) be added here?:
^(b c) --> varSize*(b b b) --> varSize+(b b b) --> +(b c) --> +(2 b) or +(2 c)


+(b c)                                                              --> +(2 b) or +(2 c)
*(b c)                                                   --> +(b c) --> +(2 b) or +(2 c)
varSize+(b b b)                                          --> +(b c) --> +(2 b) or +(2 c)
varSize*(b b b)                      --> varSize+(b b b) --> +(b c) --> +(2 b) or +(2 c)
^(b c)          <--> varSize*(b b b) --> varSize+(b b b) --> +(b c) --> +(2 b) or +(2 c)

Simplify:
+(2 b) or +(2 c)                                                                         --> 2
+(b c)                                                              --> +(2 b) or +(2 c) --> 2
*(b c)                                                   --> +(b c) --> +(2 b) or +(2 c) --> 2
varSize+(b b b)                                          --> +(b c) --> +(2 b) or +(2 c) --> 2
varSize*(b b b)                      --> varSize+(b b b) --> +(b c) --> +(2 b) or +(2 c) --> 2

null is 0.

Simplify:
null                                                                                               --> error
1                                                                                         --> null --> error
2                                                                                   --> 1 --> null --> error
+(b c)                                                                        --> 2 --> 1 --> null --> error
*(b c)                                                             --> +(b c) --> 2 --> 1 --> null --> error
varSize+(b b b)                                         --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error
varSize*(b b b)                     --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error
^(b c)          --> varSize*(b b b) --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error

Reorder so more information is to the left of the arrows. Null is 0, and error can be ignored. Type of operator can be stored in a byte.
null                                                                                      --> error
1                                                                                --> null --> error
2                                                                          --> 1 --> null --> error
+(b c)                                                               --> 2 --> 1 --> null --> error
*(b c)                                                    --> +(b c) --> 2 --> 1 --> null --> error
varSize+(b b b)                                --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error
^(b c)                     --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error
varSize*(b b b) --> ^(b c) --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error

0   null                                                                                      --> error
1   1                                                                                --> null --> error
2p  2                                                                          --> 1 --> null --> error
3p  +(b c)                                                               --> 2 --> 1 --> null --> error
4   *(b c)                                                    --> +(b c) --> 2 --> 1 --> null --> error
5p  varSize+(b b b)                                --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error
6   ^(b c)                     --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error
7p  varSize*(b b b) --> ^(b c) --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> null --> error

p means prime. Do the 4 prime things in those 8 things mean anything about prime numbers in general?

???
Not prime: 0, 1, *, ^
Prime:     2, +, varSize+, varSize*
???


varSize*(b b b) --> ^(b c) --> varSize+(b b b) --> *(b c) --> +(b c) --> 2 --> 1 --> 0


[THIS IS IMPORTANT]
7p                          6          5p                          4          3p         2p     1     0
varSize*(3 3 3 3 3 3 3) --> ^(3 7) --> varSize+(3 3 3 3 3 3 3) --> *(3 7) --> +(3 7) --> 2  --> 1 --> 0

Every node is constant size + which contains different types of varSize+ and possibly varSize* and combinations of these 8 things.

Should varSize* and varSize+ have an extra parameter that is array size?
Example: varSize*(7 3 3 3 3 3 3 3) or it may be better written as varSize*(3 3 3 3 3 3 3)[7]
Example: varSize+(4 3 3 3 3) or it may be better written as  varSize+(3 3 3 3)[4]

varSize*(3 3 3 3 3 3 3)[?]
^(3 7)[2]
varSize+(3 3 3 3 3 3 3)[?]
*(3 7)[2]
+(3 7)[2]
2[1]
1[0] //should this be 1[1]? //You cant choose 1 of 1 things if you have 0 data to express that choice. You have to define what that 1 thing is somewhere. For that, we need more than 1 number: size and currentIndex.
0[error] //should this be 0[0]?



[END: THIS IS IMPORTANT]

varSize^ would be next, and varSize^^ may be the version that evaluates right to left to get an exponentially bigger result.
varSize^(3 3 3) means ^(^(3 3) 3), and varSize^^(3 3 3) means ^(3 ^(3 3))


Can any nonnegative int be defined in terms of these 8 things, starting with 0 and 1?

7                           6          5                           4          3          2      1     0
varSize*(3 3 3 3 3 3 3) --> ^(3 7) --> varSize+(3 3 3 3 3 3 3) --> *(3 7) --> +(3 7) --> 2  --> 1 --> 0

varSize* defines positional number systems with any positive base.
Lets choose base 2 in this example.
varSize*(2 2 2 2 2 2 2)

Start simpler...
0
1
2
3 = +(b c), Example: +(2 1)
4 = *(b c), Example:
5 = varSize+(1 1 1 1 1)
6 = ^(3 7)


</createExampleNode.controlFlowDataStructure>
